package com.ssy.lingxi.contract.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.contract.api.model.vo.request.ContrPriceQueryRequest;
import com.ssy.lingxi.contract.api.model.vo.request.ContractPageRequest;
import com.ssy.lingxi.contract.api.model.vo.request.PayApplyAmountVO;
import com.ssy.lingxi.contract.api.model.vo.request.PurchaseMaterielPriceRequestVO;
import com.ssy.lingxi.contract.api.model.vo.response.ContractPageResponse;
import com.ssy.lingxi.contract.api.model.vo.response.ContractPriceQueryVO;
import com.ssy.lingxi.contract.api.model.vo.response.PurchaseMaterielPriceVO;
import com.ssy.lingxi.contract.service.IApplyAmountOrderService;
import com.ssy.lingxi.contract.service.IContractCoordinationService;
import com.ssy.lingxi.contract.service.IContractPurchaseMaterielService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 合同-内部接口
 * @author 伍将
 * @date 2021/3/11
 * @version 2.0.0
 */
@RestController
@RequestMapping("/contract/feign")
public class ContractFeignController {

    @Resource
    private IContractPurchaseMaterielService purchaseMaterielService;

    @Resource
    private IApplyAmountOrderService applyAmountOrderService;
    @Resource
    private IContractCoordinationService contractCoordinationService;
    /**
     * 查询采购物料单价
     * @author 伍将
     * @date 2021/3/19
     **/
    @RequestMapping("/getPurchaseMaterielPriceList")
    public Wrapper<List<PurchaseMaterielPriceVO>> getPurchaseMaterielPriceList(@RequestBody @Valid PurchaseMaterielPriceRequestVO requestVO) {
        return purchaseMaterielService.getPriceList(requestVO);
    }

    /**
     * 支付请款
     * @author 伍将
     * @date 2021/3/24
     **/
    @RequestMapping("/payApplyAmount")
    public Wrapper<Void> payApplyAmount(@RequestBody @Valid PayApplyAmountVO payVO) {
        return applyAmountOrderService.payApplyAmount(payVO);
    }

    /**
     * 查询合同-(合同乙方请款时查询)
     * @author 伍将
     * @date 2021/3/19
     **/
    @PostMapping("/page/by/partb")
    public Wrapper<PageData<ContractPageResponse>> pageContractByPartB(@RequestBody @Valid ContractPageRequest requestVO)
    {
        return contractCoordinationService.pageContractByApplyAmount(requestVO);
    }

    /**
     * 根据物料信息查询合同(商品能力- 物料价格库)
     * @author lxc
     * @date 2022/3/28
     **/
    @PostMapping("/goodsPrice/by/goods")
    public Wrapper<ContractPriceQueryVO> goodsPriceByGoods(@RequestBody @Valid ContrPriceQueryRequest request)
    {
        return contractCoordinationService.goodsPriceByGoods(request);
    }
}
